package top.milkbox.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.milkbox.domain.Order;
import top.milkbox.service.OrderService;
import top.milkbox.utils.R;

import java.util.List;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 通过快递公司或订单号查询订单
     */
    @GetMapping()
    public R findByCompanyAndOrderNumber(
            @RequestParam(value = "company" , required = false) String company,
            @RequestParam(value = "orderNumber" , required = false) String orderNumber) {
            List<Order> orderList = orderService.findByCompanyAndOrderNumberOrder(
                    company, orderNumber);

            return new R(true, orderList, "本接口由milkbox提供，接口中的数据均为模拟数据！");
        }
    }
